%-------------------------------------------------------------------------
% Main File: National-Level Results 
%
% Estimation Codes for National-Level Results in  
% Ben-David, Itzhak, Sebastian Weber, and Pascal Towbin 
% "Inferring Expectations from Observables: Evidence from the Housing Market" 
% Review of Economics and Statistics
% ------------------------------------------------------------------------ 

%% DATA MANIPULATION
clear
close all

%% Set Directories
dir=pwd;
outputfolder=fullfile(dir,'output', filesep); %Create a folder "output" in your working directory before you run the code.
addpath 'auxilliary'

parametersanddata   %file to adjust some estimation parameters (e.g. numbers of accepted draws)
estimation_identification  %Estimates SVAR and imposes sign restrictions 

%% Output 1 Impulse Response Functions
irf_figure %%  Figure 2 (with paramuc=1)


%% Output2 2 Historical Decomposition
n_decomp=n_price;  % Set variable that should be decomposed
gapstart= T-nlags; % Historical Decomp for full period
comp_histdecomp;
figno='3';           % Figure number label
histdecomp_figure    % Figure 3  
hist_decomp_figure_percentiles %Figure 4 and Input for Table 2 (sheet Sumperc)
